<!--
<script setup>

</script>

<template>
伙食汇总
</template>

<style scoped>

</style>-->
<!--
<script setup>

</script>

<template>
伙食汇总
</template>

<style scoped>

</style>-->
<script setup>
import { ref, computed } from 'vue';
import { ElInput, ElSelect, ElOption, ElButton, ElForm, ElFormItem, ElTable, ElTableColumn } from 'element-plus';

const data = ref([
  { name: '张三', status: 'active', date: '2023-05-01' },
  { name: '李四', status: 'inactive', date: '2023-05-02' },
  // 更多数据...
]);

const searchQuery = ref({ name: '', status: '' });

const filteredData = computed(() => {
  return data.value.filter(item => {
    return (searchQuery.value.name ? item.name.includes(searchQuery.value.name) : true) &&
        (searchQuery.value.status ? item.status === searchQuery.value.status : true);
  });
});

const fetchData = async () => {
  // 可以在这里调用 API 根据 searchQuery 获取数据
  console.log('查询条件:', searchQuery.value);
};
</script>
<template>
  <div class="searchable-list">
    <el-form inline>
      <el-form-item label="姓名">
        <el-input v-model="searchQuery.name" placeholder="请输入姓名"></el-input>
      </el-form-item>
      <el-form-item label="状态" style="width:180px">
        <el-select v-model="searchQuery.status" placeholder="请选择状态">
          <el-option label="全部" value=""></el-option>
          <el-option label="活跃" value="active"></el-option>
          <el-option label="非活跃" value="inactive" ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="fetchData">查询</el-button>
      </el-form-item>
    </el-form>
    <el-table :data="filteredData" style="width: 100%">
      <el-table-column prop="name" label="姓名"></el-table-column>
      <el-table-column prop="status" label="状态"></el-table-column>
      <el-table-column prop="date" label="日期"></el-table-column>
    </el-table>
  </div>
</template>
<style scoped>
.searchable-list {
  padding: 20px;
}

.el-form-item {
  margin-right: 10px;
}
</style>